package com.qf.flash.ui.home.adapter;

import android.graphics.Color;
import android.text.SpannableStringBuilder;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.qf.flash.R;
import com.qf.flash.model.GameGroupBean;
import com.qf.flash.utils.ImageLoader;
import com.qf.flashlib.adapter.BaseRViewItem;
import com.qf.flashlib.adapter.RViewHolder;
import com.qf.flashlib.util.SpannableStringUtil;

/**
 * 创建日期：2020/2/23 on 11:59
 * 描述:
 * 作者:戴旭东
 */
public class GameGroupItem2 extends BaseRViewItem<Object> {

    @Override
    public boolean isItemView(Object entity, int position) {
        return entity instanceof GameGroupBean;
    }

    @Override
    public int getItemLayout() {
        return R.layout.item_group2;
    }

    @Override
    public void convert(RViewHolder holder, Object entity, int position, int itemSize) {
        GameGroupBean bean = (GameGroupBean) entity;
        holder.setOnClickListener(R.id.cv_group);
        String str = bean.getPayedNum() + " / " + bean.getNeedNum();
        SpannableStringBuilder stringBuilder = SpannableStringUtil.changeTextColor(str, Color.parseColor("#FABE00"),0, 1);
        holder.setText(R.id.tv_count, stringBuilder)
                .setText(R.id.tv_name,bean.getTeamName())
                .setText(R.id.tv_group_no, bean.getOrderNumber())
                .setText(R.id.tv_nick_name, bean.getCaptainName())
                .setText(R.id.tv_time, bean.getGameTime())
                .setText(R.id.tv_type, bean.getTypeName())
                .setText(R.id.tv_bus_name,bean.getShop().getName())
                .setText(R.id.tv_address, bean.getShop().getLocation());
        TextView tvJiaoBiao =  holder.getView(R.id.tv_jiaobiao);
        if ("1".equals(bean.getIsFree())) {
            tvJiaoBiao.setVisibility(View.VISIBLE);
        } else {
            tvJiaoBiao.setVisibility(View.GONE);
        }
        ImageView ivImg = holder.getView(R.id.iv_img);
        ImageLoader.loadRoundCorners(ivImg.getContext(), bean.getPlayImage(), ivImg, 5);
    }
}
